#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MaxSize 10

typedef int ElemType;
typedef struct Queue{
    ElemType data[MaxSize];
    int front, rear;
}SqQueue;

void initQueue(SqQueue *Q);
bool isEmpty(SqQueue Q);
bool inQueue(SqQueue *Q, ElemType elem);
bool outQueue(SqQueue *Q, ElemType *elem);

int main(){
    SqQueue Q;
    int elem1, elem2;
    initQueue(&Q);
    printf("%d\n", isEmpty(Q));
    inQueue(&Q, 100);
    inQueue(&Q, 200);
    outQueue(&Q, &elem1);
    outQueue(&Q, &elem2);
    printf("%d, %d", elem1, elem2);
    return 0;
}

void initQueue(SqQueue *Q){
    Q->front = 0;
    Q->rear = 0;
}

bool isEmpty(SqQueue Q){
    if(Q.front==Q.rear) return true;
    return false;
}

bool inQueue(SqQueue *Q, ElemType elem){
    if((Q->rear+1)%MaxSize==Q->front) return false;
    Q->data[Q->rear] = elem;
    Q->rear = (Q->rear+1)%MaxSize;
    return true;
}

bool outQueue(SqQueue *Q, ElemType *elem){
    if(Q->front==Q->rear) return false;
    *elem = Q->data[Q->front];
    Q->front = (Q->front+1)%MaxSize;
    return true;
}